package com.ms.erpBase;

import java.util.Date;

import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Page;
import com.ms.common.model.PreCost;
import com.ms.common.util.MsUtility;

public class PreCostController extends Controller {

	public void createOrUpdate(){
	
		PreCost be=getBean(PreCost.class);
		if(be.getId()==null){
			be.setOperDate(new Date());
			be.save();
		}else{
			be.update();
		}
		renderJsp("/jsp/preCost/list.jsp");
	}
	
	
	public void list(){
		Page<PreCost> page = PreCost.dao.findPageConditions(getModel(PreCost.class),getParaToInt("page"),getParaToInt("rows") );
		renderJson(MsUtility.TransToEasyUiPage(page));
		
	}
	
	public void edit(){
		String id=getPara("id");
		PreCost be=PreCost.dao.findById(id);
		setAttr("PreCost", be);
		renderJsp("/jsp/preCost/form.jsp");
	}
	
	public void beginCreate(){
		renderJsp("/jsp/preCost/form.jsp");
	}
	
	public void delete(){
		String ids=getPara("items");
		String[] idarr=ids.split(",");
		for (String id : idarr) {
			PreCost.dao.deleteById(id);
		}
		
		
	}

}
